package Job;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Arrays;

public class Job01 {

	public static void main(String[] args) {
		/**
		 * 一个文件中保存了一行数据，数据用逗号分隔，请读取出数据，进行升序排序，然后将排好序的数据写入文件。
		 */
		
		FileInputStream fis = null;
		FileOutputStream fos = null;
		try {
			
			 fis = new FileInputStream("T");
			 
			 fos = new FileOutputStream("T",true);
			 
			 byte[] by = new byte[fis.available()];
			 fis.read(by);
			 Arrays.sort(by);
			 
			 fos.write(by);
			 
			 fos.flush();
			 
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		} finally {
			if(fos != null){
				try {
					fos.close();
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			
			if(fis != null){
				try {
					fis.close();
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
		}

	}

}
